package com.automatastudios.notifications {
	/**
	 * The Notification is the object broadcast by the NotificationCenter when instructed by a notification sender. This object 
	 * encapsulates all the information the sender wishes to pass along to registered observers, including the notificaiton name, 
	 * a reference to the sender, and any data the sender chooses to pass.  Also, the NotificationCenter adds data to the notification 
	 * at the time of broadcast as instructed by the registered observer at the time the observer was added.
	 * 
	 * <p>A sender creates an instance of Notification, adding the notification name, a reference to itself, and data. The sender then 
	 * calls NotificationCenter.notify(), passing the notification object as a parameter.  As a best practice, notification names should 
	 * be contained in a class, where each name is represented as a static public property.
	 * </p>
	 * 
	 * @see NotificationCenter
	 * @see NotificationCenter#notify()
	 */
	public class Notification {
		
		/**
		 * The name of this notification
		 */
		public var name:String;
		
		/**
		 * A reference to the object that is sending this notification
		 */
		public var sender:Object;
		
		/**
		 * Any data the sender wishes to send with this notification
		 */
		public var senderData:*;
		
		/**
		 * Any data the observer wishes to receive with this notification
		 */
		public var observerData:*;
		
		/**
		 * The Notification constructor creates a new notification object.
		 * 
		 * @param name the name of the new notification
		 * @param reference to the sender of the new notification
		 * @param senderData optional data sent with the new notification
		 */
		public function Notification(name:String, sender:Object, senderData:* = null)
		{
			this.name = name;
			this.sender = sender;
			this.senderData = senderData;
		}
		
		/**
		 * Method returns a string representation of this object
		 * 
		 * @return string representation of this object
		 */
		public function toString():String 
		{
			var str:String;
			str = "**** Notification ****\n";
			str += "name = " + name + "\n";
			str += "sender = " + sender.name + "\n";
			str += "senderData = " + senderData + "\n";
			str += "observerData = " + observerData + "\n";
			str += "**********************\n";
			
			return str;
		}
	}
}